﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Net;
using System.Configuration;

/// <summary>
/// Summary description for SendMailHelper
/// </summary>
public class SendMailHelper
{
	public SendMailHelper()
	{
		
	}

    public static void SendEmail(string mailTo, string title, string body ) {
        MailMessage objEmail = new MailMessage();
        string fromEmail = ConfigurationManager.AppSettings["Mail_From"];
        string password = ConfigurationManager.AppSettings["Mail_From_Pwd"];
        objEmail.To.Add(mailTo);
        objEmail.From = new MailAddress(fromEmail);
        objEmail.Subject = title;
        objEmail.Body = body;
        objEmail.IsBodyHtml = true;
        string host = ConfigurationManager.AppSettings["Mail_Smtp_Host"];
        SmtpClient client = new SmtpClient();
        client.Host = host;
        client.Port = Convert.ToInt32( ConfigurationManager.AppSettings["Mail_Smtp_Port"]);
        client.EnableSsl = true;

        NetworkCredential SMTPUserInfo = new NetworkCredential(fromEmail, password);
        client.UseDefaultCredentials = false;
        client.Credentials = SMTPUserInfo;

        client.Send(objEmail);
    }
}